#include <stdio.h>
int isLeapYear(int year) {
    return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}
int dayOfYear(int year, int month, int day) {
    int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int sum = 0;
    int i;
    if (isLeapYear(year)) {
        days[1] = 29;
    }
    for (i = 0; i < month - 1; i++) {
        sum += days[i];
    }
    sum += day;
    return sum;
}
int main() {
    int year, month, day;
    scanf("%d%d%d", &year,&month,&day);
    int result = dayOfYear(year, month, day);
    printf("%d", result);
    return 0;
}
